home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / source / gfxfx / picload.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1994-04-20  |  2.0 KB  |  98 lines

  1. {$I-,V-}
  2.  
  3. program PictureLoader;
  4. { Displays raw pictures (same as datload, but now with pal at $20 and
  5.   data at $320), by Bas van Gaalen, Holland, PD }
  6. uses
  7.   crt,dos;
  8.  
  9. const
  10.   Gseg = $A000;
  11.  
  12. type
  13.   Str80 = string[80];
  14.   BufTp = array[0..4095] of byte;
  15.   PalBuf = array[0..$2ff] of byte;
  16.  
  17. var
  18.   PicFile  : file;
  19.   Palette  : PalBuf;
  20.   Buffer   : BufTp;
  21.   FileName : pathstr;
  22.   I,BufCt  : word;
  23.   NofRead  : integer;
  24.  
  25. {----------------------------------------------------------------------------}
  26.  
  27. procedure Error(Err : Str80);
  28.  
  29. begin
  30.   writeln;
  31.   writeln(Err);
  32.   halt(1);
  33. end;
  34.  
  35. {----------------------------------------------------------------------------}
  36.  
  37. procedure SetGraphics(Mode : byte); assembler;
  38.  
  39. asm
  40.   mov AH,0
  41.   mov AL,Mode
  42.   int 10h
  43. end;
  44.  
  45. {----------------------------------------------------------------------------}
  46.  
  47. procedure InstallColors(Buf : PalBuf);
  48.  
  49.   procedure SetColor(Color,Red,Green,Blue : byte);
  50.  
  51.   begin
  52.     port[$3C8] := Color;
  53.     port[$3C9] := Red;
  54.     port[$3C9] := Green;
  55.     port[$3C9] := Blue;
  56.   end;
  57.  
  58. var
  59.   I : byte;
  60.   C : word;
  61.  
  62. begin
  63.   C := 0;
  64.   for I := 0 to 255 do begin
  65.     SetColor(I,Buf[C],Buf[C+1],Buf[C+2]);
  66.     inc(C,3);
  67.   end;
  68. end;
  69.  
  70. {----------------------------------------------------------------------------}
  71.  
  72. begin
  73.   FileName := paramstr(1);
  74.   if FileName = '' then begin
  75.     writeln('Load raw picture. Please enter filename on commandline.');
  76.     halt;
  77.   end;
  78.   assign(PicFile,FileName);
  79.   reset(PicFile,1); if ioresult <> 0 then Error(FileName+' not found in current dir');
  80.  
  81.   seek(PicFile,$20);
  82.   blockread(PicFile,Palette,$300);
  83.   SetGraphics($13);
  84.   InstallColors(Palette);
  85.  
  86.   seek(PicFile,$320);
  87.   BufCt := 0;
  88.   repeat
  89.     blockread(PicFile,Buffer,4096,NofRead);
  90.     for I := 0 to NofRead-1 do mem[Gseg:BufCt+I] := Buffer[I];
  91.     inc(BufCt,NofRead);
  92.   until NofRead < 4096;
  93.   close(PicFile);
  94.  
  95.   repeat until keypressed;
  96.   SetGraphics(3);
  97. end.
  98.